home *** CD-ROM | disk | FTP | other *** search
- package org.flintparticles.counters
- {
- import org.flintparticles.emitters.Emitter;
-
- public class Steady implements Counter
- {
-
-
- private var _rateMax:Number;
-
- private var _stop:Boolean;
-
- private var _rateMin:Number;
-
- private var _timeToNext:Number;
-
- public function Steady(param1:Number, param2:Number = NaN)
- {
- super();
- _stop = false;
- _rateMin = param1;
- _rateMax = isNaN(param2) ? param1 : param2;
- }
-
- public function get rate() : Number
- {
- return _rateMin == _rateMax ? _rateMin : (_rateMax + _rateMin) * 0.5;
- }
-
- public function set rateMin(param1:Number) : void
- {
- _rateMin = param1;
- }
-
- public function stop() : void
- {
- _stop = true;
- }
-
- public function startEmitter(param1:Emitter) : uint
- {
- _timeToNext = newTimeToNext();
- return 0;
- }
-
- public function resume() : void
- {
- _stop = false;
- }
-
- public function get rateMin() : Number
- {
- return _rateMin;
- }
-
- public function set rateMax(param1:Number) : void
- {
- _rateMax = param1;
- }
-
- public function set rate(param1:Number) : void
- {
- _rateMax = _rateMin = param1;
- }
-
- public function get rateMax() : Number
- {
- return _rateMax;
- }
-
- private function newTimeToNext() : Number
- {
- var _loc1_:Number = NaN;
- _loc1_ = _rateMin == _rateMax ? _rateMin : _rateMin + Math.random() * (_rateMax - _rateMin);
- return 1 / _loc1_;
- }
-
- public function updateEmitter(param1:Emitter, param2:Number) : uint
- {
- var _loc3_:uint = 0;
- if(_stop)
- {
- return 0;
- }
- _loc3_ = 0;
- _timeToNext -= param2;
- while(_timeToNext <= 0)
- {
- _loc3_++;
- _timeToNext += newTimeToNext();
- }
- return _loc3_;
- }
- }
- }
-